-
Notifications
You must be signed in to change notification settings - Fork 1k
Added note about copying elements during conversion #1643
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
scala/bug#11872 In addition, the method introduction was modified to the latest method list.
@@ -22,7 +22,7 @@ Collection classes that implement `Iterable` just need to define this method; al | |||
|
|||
* **Addition**, `concat`, which appends two collections together, or appends all elements of an iterator to a collection. | |||
* **Map** operations `map`, `flatMap`, and `collect`, which produce a new collection by applying some function to collection elements. | |||
* **Conversions** `toArray`, `toList`, `toIterable`, `toSeq`, `toIndexedSeq`, `toStream`, `toSet`, `toMap`, which turn an `Iterable` collection into something more specific. All these conversions return their receiver argument unchanged if the run-time type of the collection already matches the demanded collection type. For instance, applying `toList` to a list will yield the list itself. | |||
* **Conversions** `to`, `toList`, `toVector`, `toMap`, `toSet`, `toSeq`, `toIndexedSeq`, `toBuffer`, `toArray` which turn an `Iterable` collection into something more specific. If the destination is a mutable collection(to(collection.mutable.X), to(collection.X), toArray, toBuffer), a new collection is created by copying the original elements. All these conversions return their receiver argument unchanged if the run-time type of the collection already matches the demanded collection type. For instance, applying `toList` to a list will yield the list itself. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like some missing backquotes here, to make to(collection.mutable.X)
and so forth render in monospace font
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks!
fixed it.
I'm wondering about the presence of And regardless, it doesn't seem correct to me for the phrasing to imply that |
interested in getting this across the finish line? |
@magnolia-k interested in getting this across the finish line? |
I'm sorry it took me so long to reply. It's true, as you point out, not all of the to(collection.X) generates a copy. |
thank you! |
scala/bug#11872
In addition, the method introduction was modified to the latest method list.